
<?php 

////Выбираем прикрепленные каталоги и формируем массив
$fd = $form->getObject()->getMat2Folders();
$arr = array();
foreach($fd as $d)
{
	$arr[$d->getFolderId()] = $d->getFolderId();
}
///

$c = new Criteria();
$c->add(FolderPeer::SCOPE,1);
$c->addAnd(FolderPeer::TREE_LEFT,1,Criteria::NOT_EQUAL);
$c->addAscendingOrderByColumn(FolderPeer::TREE_LEFT);
$fl = FolderPeer::doSelect($c);
?>

<tr>
<th><label>Тип предприятия</label></th>
<td>

 <?php $fd1 = $form->getObject()->getMat2Folders();?>   
<?php if($fd1):?>
<table>
	<tr>
	<td>
	
    <input id="sf_admin_list_batch_checkbox1" checked="checked" type="checkbox" onclick="checkUni('1');" />
	Выбранные каталоги:
	</td>
	<td>
	
	<?php foreach($fd1 as $d):?>
	 <?php if($d->getFolder()->getScope()==1):?>
			&nbsp;<?php echo checkbox_tag('material[mat2_folder_list][]', $d->getFolderId(), true,'class="sf_admin_batch_checkbox1"') ?>
	
		<?php if($d->getFolder()->getLevel()==1){echo '<b>'.$d->getFolder().'</b>';} else { echo $d->getFolder(); }?>
	 <?php endif ?>	
	<?php endforeach ?>
	</td>
	</tr>
</table>
<?php endif ?>


<ul >
<?php foreach($fl as $f):?>
	<li style="<?php if($f->getLevel()==1) echo "padding:10px 0 0 0"?>;list-style-type: none; padding-left: <?php echo $f->getLevel()*22?>px">
		<?php if(in_array($f->getId(),$arr)):?>
			<?php echo image_tag('/images/icons/checkbox.gif')?>
		<?php else: ?>
			<?php echo checkbox_tag('material[mat2_folder_list][]', $f->getId(), false) ?>
		<?php endif ?>
		&nbsp;
		<label for="material_mat2_folder_list_<?php echo $f->getId()?>">
		<?php if($f->getLevel()==1){echo '<b>'.$f.'</b>';} else { echo $f; }?>
		</label>
	</li>
<?php endforeach ?>
</ul>
</td>
</tr>

<?php 
$c = new Criteria();
$c->add(FolderPeer::SCOPE,3);
$c->addAnd(FolderPeer::TREE_LEFT,1,Criteria::NOT_EQUAL);
$c->addAscendingOrderByColumn(FolderPeer::TREE_LEFT);
$fl = FolderPeer::doSelect($c);
?>

<tr>
<th><label>Вид деятельности</label></th>
<td>
	<?php $fd3 = $form->getObject()->getMat2Folders();?>
	<?php if($fd3):?>
	    <table>
		<tr>
		<td>
		<input id="sf_admin_list_batch_checkbox3" checked="checked" type="checkbox" onclick="checkUni('3');" />
		Выбранные каталоги:
		</td>
		<td>
	
		<?php foreach($fd3 as $d):?>
		    <?php if($d->getFolder()->getScope()==3):?>
				&nbsp;<?php echo checkbox_tag('material[mat2_folder_list][]', $d->getFolderId(), true,'class="sf_admin_batch_checkbox3"') ?>
		
			    <?php if($d->getFolder()->getLevel()==1){echo '<b>'.$d->getFolder().'</b>';} else { echo $d->getFolder(); }?>
			<?php endif ?>
		<?php endforeach ?>
		</td>
		</tr>
	    </table>
   <?php endif ?>
<ul >
<?php foreach($fl as $f):?>
	<li style="<?php if($f->getLevel()==1) echo "padding:10px 0 0 0"?>;list-style-type: none; padding-left: <?php echo $f->getLevel()*22?>px">
		<?php if(in_array($f->getId(),$arr)):?>
			<?php echo image_tag('/images/icons/checkbox.gif')?>
		<?php else: ?>
			<?php echo checkbox_tag('material[mat2_folder_list][]', $f->getId(), false) ?>
		<?php endif ?>
		&nbsp;
		<label for="material_mat2_folder_list_<?php echo $f->getId()?>">
		<?php if($f->getLevel()==1){echo '<b>'.$f.'</b>';} else { echo $f; }?>
		</label>
	</li>
<?php endforeach ?>
</ul>
</td>
</tr>

<?php 
$c = new Criteria();
$c->add(FolderPeer::SCOPE,5);
$c->addAnd(FolderPeer::TREE_LEFT,1,Criteria::NOT_EQUAL);
$c->addAscendingOrderByColumn(FolderPeer::TREE_LEFT);
$fl = FolderPeer::doSelect($c);
?>

<tr>
<th><label>Регионы</label></th>
<td>
	<?php $fd3 = $form->getObject()->getMat2Folders();?>
	<?php if($fd3):?>
	    <table>
		<tr>
		<td>
		<input id="sf_admin_list_batch_checkbox3" checked="checked" type="checkbox" onclick="checkUni('5');" />
		Выбранные каталоги:
		</td>
		<td>
	
		<?php foreach($fd3 as $d):?>
		    <?php if($d->getFolder()->getScope()==5):?>
				&nbsp;<?php echo checkbox_tag('material[mat2_folder_list][]', $d->getFolderId(), true,'class="sf_admin_batch_checkbox3"') ?>
		
			    <?php if($d->getFolder()->getLevel()==1){echo '<b>'.$d->getFolder().'</b>';} else { echo $d->getFolder(); }?>
			<?php endif ?>
		<?php endforeach ?>
		</td>
		</tr>
	    </table>
   <?php endif ?>
<ul >
<?php foreach($fl as $f):?>
	<li style="<?php if($f->getLevel()==1) echo "padding:10px 0 0 0"?>;list-style-type: none; padding-left: <?php echo $f->getLevel()*22?>px">
		<?php if(in_array($f->getId(),$arr)):?>
			<?php echo image_tag('/images/icons/checkbox.gif')?>
		<?php else: ?>
			<?php echo checkbox_tag('material[mat2_folder_list][]', $f->getId(), false) ?>
		<?php endif ?>
		&nbsp;
		<label for="material_mat2_folder_list_<?php echo $f->getId()?>">
		<?php if($f->getLevel()==1){echo '<b>'.$f.'</b>';} else { echo $f; }?>
		</label>
	</li>
<?php endforeach ?>
</ul>
</td>
</tr>
